package net.sf.graph4j.datastructure.disjointset.forest;
import net.sf.graph4j.datastructure.disjointset.IDisjointSet;

/**
 * 
 */

/**
 * In a faster implementation of disjoint sets, we represent sets by rooted
 * trees, with each node containing one member and each tree representing one
 * set. In a disjoint-set forest, illustrated in Figure 21.4(a), each member
 * points only to its parent. The root of each tree contains the representative
 * and is its own parent. As we shall see, although the straightforward
 * algorithms that use this representation are no faster than ones that use the
 * linked-list representation, by introducing two heuristics-"union by rank" and
 * "path compression"-we can achieve the asymptotically fastest disjoint-set
 * data structure known.
 * 
 * @author chen cong
 * 
 */
public class DisjointSetImpl2<E> implements IDisjointSet<E> {

	private DisjointSetNode2<E> root;

	/**
	 * @param root
	 */
	public DisjointSetImpl2(DisjointSetNode2<E> root) {
		super();
		// TODO Auto-generated constructor stub
		this.root = root;
	}

	/**
	 * @return Returns the root.
	 */
	public DisjointSetNode2<E> getRoot() {
		return root;
	}

	/**
	 * @param root The root to set.
	 */
	public void setRoot(DisjointSetNode2<E> root) {
		this.root = root;
	}
	
}
